using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity.ModelConfiguration;

namespace ConsoleApplication2.Models.Mapping
{
    public class vNetSaleMap : EntityTypeConfiguration<vNetSale>
    {
        public vNetSaleMap()
        {
            // Primary Key
            this.HasKey(t => new { t.number, t.Date, t.STORENUM, t.StorName, t.StorId, t.salesmenId, t.SalesmanName, t.Doctype, t.id, t.symbol });

            // Properties
            this.Property(t => t.base1)
                .HasMaxLength(5);

            this.Property(t => t.base2)
                .HasMaxLength(5);

            this.Property(t => t.company)
                .HasMaxLength(110);

            this.Property(t => t.CustId)
                .HasMaxLength(6);

            this.Property(t => t.CustPhone)
                .HasMaxLength(20);

            this.Property(t => t.number)
                .IsRequired()
                .HasMaxLength(8);

            this.Property(t => t.STORENUM)
                .HasDatabaseGeneratedOption(DatabaseGeneratedOption.None);

            this.Property(t => t.StorName)
                .IsRequired()
                .HasMaxLength(30);

            this.Property(t => t.StorId)
                .HasDatabaseGeneratedOption(DatabaseGeneratedOption.None);

            this.Property(t => t.salesmenId)
                .HasDatabaseGeneratedOption(DatabaseGeneratedOption.None);

            this.Property(t => t.SalesmanName)
                .IsRequired()
                .HasMaxLength(30);

            this.Property(t => t.CustName)
                .HasMaxLength(35);

            this.Property(t => t.Doctype)
                .HasDatabaseGeneratedOption(DatabaseGeneratedOption.None);

            this.Property(t => t.id)
                .HasDatabaseGeneratedOption(DatabaseGeneratedOption.None);

            this.Property(t => t.symbol)
                .IsRequired()
                .HasMaxLength(5);

            // Table & Column Mappings
            this.ToTable("vNetSales");
            this.Property(t => t.base1).HasColumnName("base1");
            this.Property(t => t.base2).HasColumnName("base2");
            this.Property(t => t.company).HasColumnName("company");
            this.Property(t => t.CustId).HasColumnName("CustId");
            this.Property(t => t.CustPhone).HasColumnName("CustPhone");
            this.Property(t => t.discval).HasColumnName("discval");
            this.Property(t => t.subtotal).HasColumnName("subtotal");
            this.Property(t => t.number).HasColumnName("number");
            this.Property(t => t.Date).HasColumnName("Date");
            this.Property(t => t.STORENUM).HasColumnName("STORENUM");
            this.Property(t => t.StorName).HasColumnName("StorName");
            this.Property(t => t.StorId).HasColumnName("StorId");
            this.Property(t => t.salesmenId).HasColumnName("salesmenId");
            this.Property(t => t.SalesmanName).HasColumnName("SalesmanName");
            this.Property(t => t.total).HasColumnName("total");
            this.Property(t => t.CustName).HasColumnName("CustName");
            this.Property(t => t.Doctype).HasColumnName("Doctype");
            this.Property(t => t.id).HasColumnName("id");
            this.Property(t => t.symbol).HasColumnName("symbol");
            this.Property(t => t.cashrcvd_).HasColumnName("cashrcvd$");
            this.Property(t => t.chkrcvd_).HasColumnName("chkrcvd$");
            this.Property(t => t.ccrcvd_).HasColumnName("ccrcvd$");
            this.Property(t => t.chgrcvd_).HasColumnName("chgrcvd$");
            this.Property(t => t.cashrcvdLL).HasColumnName("cashrcvdLL");
            this.Property(t => t.chkrcvdLL).HasColumnName("chkrcvdLL");
            this.Property(t => t.ccrcvdLL).HasColumnName("ccrcvdLL");
            this.Property(t => t.chgrcvdLL).HasColumnName("chgrcvdLL");
            this.Property(t => t.Total_).HasColumnName("Total$");
            this.Property(t => t.TotalLL).HasColumnName("TotalLL");
            this.Property(t => t.Cost_).HasColumnName("Cost$");
            this.Property(t => t.CostLL).HasColumnName("CostLL");
            this.Property(t => t.profit_).HasColumnName("profit$");
            this.Property(t => t.profitLL).HasColumnName("profitLL");
            this.Property(t => t.ProfitPercent_).HasColumnName("ProfitPercent$");
        }
    }
}
